package com.sybase.gui;

/*
	Author: Leo
	Creation Date: 4-8-2012
	Creation Time: 7:43 PM
*/

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
// import javax.swing.table.*;

public class StockFrame extends JFrame {
	// Data member declaration
	private static final long serialVersionUID = 1L;
	public JTable cocoaTable;

	// Constructor
	public StockFrame() {
		cocoaTable = null;
	} // End of constructor
	
	public void setupGUI() {
		JPanel stockPanel = new JPanel();
		stockPanel.setLayout(new BorderLayout());
		JMenuBar menuBar = new JMenuBar();
		
		// File menu
		JMenu fileMenu = new JMenu("File");
		fileMenu.setMnemonic(KeyEvent.VK_F);
		JMenuItem exitItem = new JMenuItem("Exit");
		exitItem.setMnemonic(KeyEvent.VK_E);
		exitItem.setToolTipText("Exit Application");
		exitItem.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent ae) {
				System.out.println("[echo] Process terminated");
				
				System.exit(0);
			}
		});
		
		fileMenu.add(exitItem);
		
		// Help menu
		JMenuItem helpMenu = new JMenu("Help");
		helpMenu.setMnemonic(KeyEvent.VK_H);
		JMenuItem aboutItem = new JMenuItem("About");
		aboutItem.setMnemonic(KeyEvent.VK_A);
		aboutItem.setToolTipText("About Stock Frame and Cocoa");
		
		helpMenu.add(aboutItem);
		
		menuBar.add(fileMenu);
		menuBar.add(helpMenu);
		
		JScrollPane scrollPane = new JScrollPane(cocoaTable);
		scrollPane.setBorder(BorderFactory.createTitledBorder("All Results"));
		
		stockPanel.add(scrollPane, BorderLayout.CENTER);
		stockPanel.add(menuBar, BorderLayout.NORTH);
		setContentPane(stockPanel);
		
		this.setIconImage(Toolkit.getDefaultToolkit().getImage("target/icons/cocoa.jpg"));
		this.setTitle("Stock Frame (COCOA)");
		this.setDefaultCloseOperation(EXIT_ON_CLOSE);
		this.setSize(960, 640);
		// pack();
		this.setVisible(true);
	} // End of method
	
	// Legacy code
	/*
	public static void main(String[] args) {
		// Shenanigans
		System.out.println("------------------------------");
		System.out.println("[running] Stock Frame (COCOA)");
		System.out.println("------------------------------");
		System.out.print("\n");
		
		new StockFrame();
	}// End of main
	*/
	
	public void setTable(JTable cocoaTable) {
		this.cocoaTable = cocoaTable;
	}
	
} // End of class

// Scrolls
/*
component.setBorder(BorderFactory.createTitledBorder("Stock Panel"));
*/